package Transactional;
use Error;
use strict;
use warnings;
our $VERSION = 0.01;

{ package Transactional::Error;
  use base 'Error';
#  use overload ('""' => 'stringify');
}
{ package Transactional::Error::NoImpl;
  use base 'Transactional::Error';
  use overload ('""' => 'stringify');
  sub stringify { my( $this ) = @_;
		  '&'
		    . ( ref $this->{ -object }
			? ref $this->{ -object }
			: $this->{ -object }
		      )
		      . '::'
			. $this->{ -method }
			  . '() not implemented!';
		}
}
{ package Transactional::Error::BadArgument;
  use Lingua::EN::Inflect qw(ORD NUMWORDS);
  use base 'Transactional::Error';
  use overload ('""' => 'stringify');
  sub stringify { my( $this ) = @_;
		  '&'
		    . ( ref $this->{ -object }
			? ref $this->{ -object }
			: $this->{ -object }
		      )
		      . '::'
			. $this->{ -method }
			  . q{ as its }
			    . NUMWORDS( ORD( $this->{ -arg } ) )
			      . ' argument expects '
				. $this->{ -expects }
				  . ' but got '
				    . $this->{ -got };
		}
}

sub transaction_begin {
  my( $this ) = @_;
  Transactional::Error::NoImpl->throw
      ( -object => $this,
	-method => 'transaction_begin',
      );
}

sub transaction_end {
  my( $this ) = @_;
  Transactional::Error::NoImpl->throw
      ( -object => $this,
	-method => 'transaction_begin',
      );
}

sub transaction_rollback {
  my( $this ) = @_;
  Transactional::Error::NoImpl->throw
      ( -object => $this,
	-method => 'transaction_begin',
      );
}

sub transaction {
  my( $this, $coderef ) = @_;

  Transactional::Error::BadArgument->throw( -object  => $this,
					    -method  => 'transaction',
					    -expects => 'CODE',
					    -got     => ref $coderef,
					    -arg     => 1,
					  )
      unless 'CODE' eq ref $coderef;
}

1;
__END__

#################### main pod documentation begin ###################
## Below is the stub of documentation for your module. 
## You better edit it!


=head1 NAME

Transactional - Transactional abstract interface.

=head1 SYNOPSIS

  use Transactional;
  blah blah blah


=head1 DESCRIPTION

Stub documentation for this module was created by ExtUtils::ModuleMaker.
It looks like the author of the extension was negligent enough
to leave the stub unedited.

Blah blah blah.


=head1 USAGE



=head1 BUGS



=head1 SUPPORT



=head1 AUTHOR

    Eugene Grigoriev
    CPAN ID: SIZUR
    eugene.grigoriev@gmail.com
    http://search.cpan.org/~sizur

=head1 COPYRIGHT

This program is free software licensed under the...

	The BSD License

The full text of the license can be found in the
LICENSE file included with this module.


=head1 SEE ALSO

perl(1).

=cut

#################### main pod documentation end ###################


1;
# The preceding line will help the module return a true value

